using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.IO;

/// <summary>
/// Summary description for Logging
/// </summary>
public class Logging
{
    private static string GenerateDefaultLogFileName(string BaseFileName)
    {
        return AppDomain.CurrentDomain.BaseDirectory + "\\" + BaseFileName + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Year + ".log";
    }
    public static void WriteToLog(string BaseFileName, string Message)
    {
        try
        {
            string LogPath = GenerateDefaultLogFileName(BaseFileName);
            using (StreamWriter s = File.AppendText(LogPath))
            {
                s.WriteLine(DateTime.Now + "\t" + Message);
                s.WriteLine();
                s.WriteLine();
            }
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message);
        }
    }
    public static void WriteToEventLog(string Source, string Message, System.Diagnostics.EventLogEntryType EntryType)
    {
        try
        {
            if (!EventLog.SourceExists(Source))
            {
                EventLog.CreateEventSource(Source, "Application");
            }
            EventLog.WriteEntry(Source, Message, EntryType);
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message);
        }
    }
}